package com.vf.admin.miaodong.controller;

import com.vf.admin.common.BaseController;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppFans;
import com.vf.admin.miaodong.entity.AppFansClub;
import com.vf.admin.miaodong.service.AfterFansClubService;
import com.vf.admin.miaodong.service.AfterFansService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 粉丝团
 */
@Controller
@RequestMapping("/after/fansclub")
public class AfterFansClubController extends BaseController{
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    AfterFansClubService afterFansClubService;
    @Autowired
    AfterFansService afterFansService;

    /**
     * 粉丝团列表
     * @param splitPageBean
     * @param startDate  开始时间
     * @param endDate 结束时间
     * @param roomcode  房间code
     * @param phone 手机号
     * @param nick  昵称
     * @return
     */
    @RequestMapping("/list")
    public String list(SplitPageBean splitPageBean,String startDate,String endDate,String roomcode,String phone,
                       String nick){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("roomcode",roomcode);
            map.put("phone",phone);
            map.put("nick",nick);
            List<AppFansClub> list = afterFansClubService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("roomcode",roomcode);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            return this.sucess("/web/after/fansclub/list");
        }catch (Exception e){
            logger.error("查看粉丝团列表异常",e);
            return this.error("系统繁忙");
        }
    }


    /**
     * 查看粉丝成员
     * @param splitPageBean
     * @param id  粉丝团Id
     * @param startDate
     * @param endDate
     * @param nick
     * @param phone
     * @return
     */
    @RequestMapping("/fans")
    public String fensi(SplitPageBean splitPageBean,Integer id,String startDate,String endDate,String nick,String phone){
        try{
            Map<String,Object> map = new HashMap<>();
            map.put("followerid",id);
            map.put("startDate",startDate);
            map.put("endDate",endDate);
            map.put("nick",nick);
            map.put("phone",phone);
            List<AppFans> list = afterFansService.list(map,splitPageBean);

            request.setAttribute("list",list);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            request.setAttribute("nick",nick);
            request.setAttribute("phone",phone);
            request.setAttribute("id",id);
            return this.sucess("/web/after/fansclub/fans");
        }catch (Exception e){
            logger.error("查看粉丝列表异常",e);
            return this.error("系统繁忙");
        }
    }


}
